def missing_number(nums):  
    n = len(nums) + 1  
    left, right = 0, n - 1  
      
    while left <= right:  
        mid = (left + right) // 2  
        # 检测数组mid索引的值是否等于mid  
        if nums[mid] == mid:  
            left = mid + 1  
        else:  
            right = mid - 1  
      
    return left 


l1 = [0,1,3]
l2 = [0,1,2,3,4,5,6,7,9]
print(missing_number(l1))
print(missing_number(l2))

